
//{{{ file documentation -------------------------------------------------------

/*!
 * @file     messages.cpp
 * @brief    dicodor messages window class implementation
 */

//}}} --------------------------------------------------------------------------
//{{{ includes / predeclarations -----------------------------------------------

// @(#) $Id:$

#include "messages.h"
//#include "moc_messages.cpp"	moc V5 sera incompatible V4
#include "ui_messages.h"

#include <QtGui/QDialog>

//}}} --------------------------------------------------------------------------
//{{{ Messages -----------------------------------------------------------------
//}}} --------------------------------------------------------------------------
//{{{ .Messages( QWidget * parent ) --------------------------------------------

Messages::Messages( QWidget * parent ) :
	QDialog( parent ),
	ui( new Ui::Messages )
{
	ui->setupUi( this );

	initIcons();
}

//}}} --------------------------------------------------------------------------
//{{{ .~Messages() -------------------------------------------------------------

Messages::~Messages()
{
	delete ui;
}

//}}} --------------------------------------------------------------------------
//{{{ .void        initIcons() -------------------------------------------------

void Messages::initIcons ()
{
	ui->clear->setIcon (QIcon::fromTheme ("edit-clear"));
	ui->close->setIcon (QIcon::fromTheme ("window-close"));
}

//}}} --------------------------------------------------------------------------
//{{{ .void        setMessageList( const QStringList & list ) ------------------

void Messages::setMessageList( const QStringList & list )
{
	ui->list->clear();
	ui->list->addItems( list );
}

//}}} --------------------------------------------------------------------------
//{{{ .QStringList messageList() -----------------------------------------------

QStringList Messages::messageList()
{
	QStringList result;
	for( int row = 0 ; row != ui->list->count() ; row++ )
	{
		QListWidgetItem * item( ui->list->item( row ) );
		result << item->text();
	}

	return result;
}

//}}} --------------------------------------------------------------------------
//{{{ .void        changeEvent( QEvent * e ) -----------------------------------

void Messages::changeEvent( QEvent * e )
{
	QDialog::changeEvent( e );
	switch( e->type() )
	{
	case QEvent::LanguageChange:
		ui->retranslateUi( this );
		break;
	default:
		break;
	}
}

//}}} --------------------------------------------------------------------------
//{{{ .void        on_clear_clicked() ------------------------------------------

void Messages::on_clear_clicked()
{
	ui->list->clear ();
}

//}}} --------------------------------------------------------------------------
//{{{ .void        on_close_clicked() ------------------------------------------

void Messages::on_close_clicked()
{
	close ();
}

//}}} --------------------------------------------------------------------------

